﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ERPStore.Web.Start
{
	public class PluginsConfig
	{
		public static void Load(Microsoft.Practices.Unity.IUnityContainer container, System.Web.HttpContextBase ctx)
		{
			var rootFolder = ctx.Server.MapPath("/");
			var configFile = System.IO.Path.Combine(rootFolder, "plugins.config");
			var binPath = ctx.Server.MapPath("/bin");
			var pluginLoaderService = new ERPStore.Extensibility.PluginLoaderService();
			var pluginEnumeratorService = new ERPStore.Extensibility.XmlConfigPluginEnumerator(configFile, binPath);
			var plugins = pluginEnumeratorService.EnumeratePlugins();
			pluginLoaderService.Load(plugins);

			GlobalConfiguration.Configuration.Logger.Info("Plugins loaded");
		}

	}
}
